/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       wavloader.h
 * Author:     karooolek
 * Created on: 2009-03-24
 *
 **********************************************************************************************************************/

#ifndef WAVLOADER_H_
#define WAVLOADER_H_

#include "soundloader.h"

namespace mGameEngine
{
namespace Audio
{

/**
 * WAV sound file loader.
 */
class WAVLoader : public SoundLoader
{
private:
    // WAV file structures
    struct WAVHeader
    {
        char id[4];                         // "RIFF"
        uint32 fileSize;                    // file size - 8
        char format[4];                     // "WAVE"
        char fmtid[4];                      // "fmt "
        uint32 subsize;                     // 16 for PCM
        uint16 compression;                 // 1 for PCM
        uint16 nChannels;                   //
        uint32 sampleRate;                  // 8000, 44100, ...
        uint32 byteRate;                    // sampleRate*channels*bps/8
        uint16 blockAlign;                  // channels*bps/8
        uint16 bitsPerSample;               //
        char dataid[4];                     // "data"
        uint32 dataSize;                    // samples*channels*bps/8
    };

public:
    /**
     * Create WAV sound loader with no file name specified.
     */
    WAVLoader();

    /**
     * Create WAV sound file loader with specified file name.
     * @param filename WAV sound file name to load
     */
    WAVLoader(const String &filename);

    /**
     * Destroy WAV sound file loader.
     */
    ~WAVLoader();

    /**
     * Load sound from WAV file.
     */
    void load();
};

}
}

#endif // WAVLOADER_H_
